import {_decorator, Component, Label, Node} from 'cc';

import {Palette} from "db://assets/scripts/component/Palette";
import {levelEnumInfo, LevelInfo} from "db://assets/scripts/consts/Game2048LevelEnum";
const { ccclass, property } = _decorator;

@ccclass('Lv2048Tg')
export class Lv2048Tg extends Component {
    start() {

    }

    update(deltaTime: number) {
        
    }

    public init(lv: string) {

        let levelEnumInfoElement:LevelInfo = levelEnumInfo[lv];
        let palette: Palette = this.node.getComponent(Palette);
        palette.colorLB = levelEnumInfoElement.background;
        palette.colorRB = levelEnumInfoElement.background;
        palette.colorLT = levelEnumInfoElement.background;
        palette.colorRT = levelEnumInfoElement.background;

        if(levelEnumInfoElement.background2){
            palette.colorRB = levelEnumInfoElement.background2;
        }
        if(levelEnumInfoElement.background3){
            palette.colorLT = levelEnumInfoElement.background3;
        }
        if(levelEnumInfoElement.background4){
            palette.colorRT = levelEnumInfoElement.background4;
        }

        this.node.children[0].getComponent(Label).string = levelEnumInfoElement.title;
        this.node.children[0].getComponent(Label).color = levelEnumInfoElement.fontColor;

    }
}


